<%-- 
    Document   : viewcart
    Created on : Jul 3, 2011, 8:21:17 PM
    Author     : PhongLK60473
--%>

<%@page import="Object.Order"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Object.Page"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="" >
            @import url("style/style.css");
            @import url("style/viewcart.style.css");
        </style>
    </head>
    <body>
        <%@include file="header.jsp" %>
        <%
                    if (user.isGuest()) {
                        response.sendRedirect("UserController");
                    }

                    ArrayList aO = (ArrayList) sess.getAttribute("Orders");
                    if(aO==null){
                        aO = new ArrayList();
                    }
                    Object[] orders = aO.toArray();
                    
        %>
        <div id="page">
            <h1>Your Shopping Cart</h1>
            <%
                        if (orders.length == 0) {
            %>
            <h3>Currently , There is no book in your cart</h3>
            <%
                        } else {
            %>
            <table border="1" class="cart">
                <thead>
                    <tr class="title">
                        <th class=" no">No.</td>
                        <th class=" Title">Title</td>
                        <th class=" Author">Author</td>
                        <th class=" Quantity">Quantity</td>
                        <th class=" Price">Price</td>

                    </tr>
                </thead>
                <tbody>
                    <%
                    float totalPrice=0;
                    for(int i=0;i<orders.length;i++){
                        Order order=(Order) orders[i];
                    %>
                    <tr class="data">
                        <td class="no"><%= (i+1) %></td>
                        <td class="Title"><%= order.getBookTitle() %></td>
                        <td class="Author"><%= order.getBookAuthor() %></td>
                        <td class="Quantity"><%= order.getQuantity() %></td>
                        <td class="Price"><%= order.getTotalPrice() %></td>
                    </tr>
                    <%
                    totalPrice+=order.getTotalPrice();
                    }
                    
                    %>
                    <tr class="data">
                        <td colspan="4">Total</td>
                        <td class="title Price"><%= totalPrice %></td>
                    </tr>
                </tbody>
            </table>
            <br>
            <div id="checkout-cont">
                <a href="UserController?action=Checkout">
                    <img src="images/btn_goToCheckout.jpg"/>
                </a>
            </div>
            <%          }
            %>
        </div>
    </body>
</html>
